// 1. 引入对应模块
import Vue from 'vue'
import VueRouter from 'vue-router'

import My_address from "../pages/Me/Children/My_address";


//标明 文件位置
const Home = () =>
    import ('./../pages/Home/Home');
const Login = () =>
    import ('./../pages/Login/Login');
const FindPwd = () =>
    import ('../pages/Register/FindPwd');
const Register = () =>
    import ('./../pages/Register/Register');
const Stars = () =>
    import ('./../pages/Goods/Stars');
const Commodity_info = () =>
    import ('./../pages/Goods/Commodity_info');
const Find_commodity = () =>
    import ('./../pages/Goods/Find_commodity');
const Search = () =>
    import ('./../pages/Search/Search');
const Add_order = () =>
    import ('../pages/Goods/Add_order');
const Me = () =>
    import ('./../pages/Me/Me');
const ShopCar = () =>
    import ('./../pages/ShopCar/ShopCar');
const AdminLogin = () =>
    import ('./../pages/AdminLogin/AdminLogin');
const Admin = () =>
    import ('./../pages/Admin/Admin');
const SearchDetail = () =>
    import ('./../pages/SearchDetail/SearchDetail');
const ArticleDetail = () =>
    import ('../pages/Article/ArticleDetail/index.vue');
const ArticleList = () =>
    import ('../pages/Article/ArticleList/index.vue');

const Profile = () =>
    import ('./../pages/Me/Children/Profile');
const Update = () =>
    import ('./../pages/Me/Children/Update');
const EditPwd = () =>
    import ('./../pages/Me/Children/EditPwd');
const Sales_list = () =>
    import ('../pages/Me/Children/Sales_list');
const AdminSales = () =>
    import ('./../pages/Admin/Children/AdminSales');
const AddGoods = () =>
    import ('./../pages/Admin/Children/AddGoods');
const AdminGoods = () =>
    import ('./../pages/Admin/Children/AdminGoods');
const AdminUpdate = () =>
    import ('./../pages/Admin/Children/AdminUpdate');
const AdminUsers = () =>
    import ('./../pages/Admin/Children/AdminUsers');
const Collection = () =>
    import ('../pages/Me/Children/Collection.vue');

// 2. 声明使用
Vue.use(VueRouter);

// 3. 输出路由对象
export default new VueRouter({
    // 3.1 配置一级路由
    routes: [

        {
            path: '/home',
            component: Home,
            meta: { showHeaderTop: true, showHeaderSearch: true }
        },
        {
            path: '/login',
            component: Login
        },
        {
            path: '/findPwd',
            component: FindPwd
        },

        {
            path: '/register',
            component: Register
        },
        {
            path: '/search/:id/:pageNo',
            component: Search,
            meta: { showHeaderTop: true, showHeaderSearch: true }
        },
        {
            path: '/stars',
            component: Stars,
            meta: { showHeaderTop: true }

        },
        {
            path: '/commodity_info',
            component: Commodity_info,
            meta: { showHeaderTop: true }

        },
        {
            path: '/find_commodity',
            component: Find_commodity,
            meta: { showHeaderTop: true, showHeaderSearch: true }

        },
        {
            path: '/my_address',
            component: My_address,
        },
        {
            path: '/article-detail/:id',
            component: ArticleDetail,
            props: true,
            meta: { showHeaderTop: true }
        },
        {
            path: '/article',
            component: ArticleList,
            meta: { showHeaderTop: true }
        },
        {
            path: '/add_order',
            component: Add_order,
            meta: { showHeaderTop: true }
        },

        {
            path: '/me',
            component: Me,
            children: [
                { path: 'profile', component: Profile },
                { path: 'update', component: Update },
                { path: 'editpwd', component: EditPwd },
                { path: 'my_address', component: My_address },
                { path: 'sales_list', component: Sales_list },
                { path: 'collection', component: Collection },
                { path: '/me', redirect: '/me/profile' },
            ],
        },
        {
            path: '/sales_list',
            component: Sales_list
        },
        {
            path: '/shopcar',
            component: ShopCar,
            meta: { showHeaderTop: true }
        },
        {
            path: '/adminlogin',
            component: AdminLogin
        },
        {
            path: '/admin',
            component: Admin,
            children: [
                { path: 'adminsales', component: AdminSales },
                { path: 'adminusers', component: AdminUsers },
                { path: 'addgoods', component: AddGoods },
                { path: 'admingoods', component: AdminGoods },
                { path: 'adminupdate', component: AdminUpdate },
                { path: '/admin', redirect: '/admin/admingoods' }
            ],
        },
        {
            path: '/searchdetail',
            component: SearchDetail,
            meta: { showHeaderTop: true, showHeaderSearch: true }
        },
        {
            path: '/',
            redirect: '/home'
        },
    ]
});